package com.airlines.crewassignment.service.crewlocation.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.airlines.common.Page;
import com.airlines.crewassignment.dao.crewlocation.CrewAbsentMapper;
import com.airlines.crewassignment.dao.crewlocation.CrewTaskAssignmentMapper;
import com.airlines.crewassignment.entity.crewlocation.CrewAbsent;
import com.airlines.crewassignment.entity.crewlocation.CrewTaskAssignment;
import com.airlines.crewassignment.service.crewlocation.CrewAbsentService;
import com.airlines.crewassignment.service.crewlocation.CrewTaskAssignmentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chenjiantong
 * @date 2018/09/04 16:23:40
 * @company xxxx Airlines
 * @description 任务安排
 */
@Service
public class CrewTaskAssignmentServiceImpl implements CrewTaskAssignmentService {

    @Autowired
    private CrewTaskAssignmentMapper crewTaskAssignmentMapper;

    @Override
    public int insert(CrewTaskAssignment crewTaskAssignment){
        return crewTaskAssignmentMapper.insert(crewTaskAssignment);
    }

    @Override
    public int delete(Integer id){
        return crewTaskAssignmentMapper.delete(id);
    }


    @Override
    public int update(CrewTaskAssignment crewTaskAssignment){
        return crewTaskAssignmentMapper.update(crewTaskAssignment);
    }

    @Override
    public CrewTaskAssignment get(Integer id){
        return crewTaskAssignmentMapper.get(id);
    }

    @Override
    public List<CrewTaskAssignment> list(CrewTaskAssignment crewTaskAssignment){
        return crewTaskAssignmentMapper.list(crewTaskAssignment);
    }

    @Override
    public Page list(CrewTaskAssignment crewTaskAssignment, Page page){
        PageHelper.startPage(page.getPageNumber(), page.getPageSize());
        List<CrewTaskAssignment> list = crewTaskAssignmentMapper.listByFuzzy(crewTaskAssignment);
        PageInfo<CrewTaskAssignment> pageInfo = new PageInfo<CrewTaskAssignment>(list);
        page.setTotal(String.valueOf(pageInfo.getTotal()));
        page.setRows(pageInfo.getList());
        return page;
    }




}
